import { User } from '@prisma/client';
import type { NextApiRequest, NextApiResponse } from 'next'
import { prisma } from "./db";

type Data = {
    userInfo: Array<String>
}

export default async function handler(
    req: NextApiRequest,
    res: NextApiResponse<Data>
) {
    const users = await prisma.user.findMany()
    const userInfo = users.map((u) =>
        u.firstName + " " + u.lastName + ": " + u.email
    );
    res.status(200).json({ userInfo })
    await prisma.$disconnect()
}
